package com.goodwill.androidtest.thread;

public class MyMath {
    private static MyMath instance;
    private volatile int num;

    private MyMath() {
    }

    public static MyMath getInstance() {
        if (instance == null) {
            synchronized (MyMath.class) {
                if (instance == null) {
                    instance = new MyMath();
                }
            }
        }
        return instance;
    }

    public void increase() {
        synchronized (this) {
            num++;
        }
    }

    public int getNum() {
        return num;
    }
}
